<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <title>{$title}后台登录</title>

    <link rel="stylesheet" href="__JS__/layui/css/layui.css">

    <link rel="stylesheet" href="__CSS__/admin.css">

    <link rel="stylesheet" href="__CSS__/login.css">

    <link href="{$ico}" type="image/x-icon" rel="shortcut icon" />

    <script>

        /*保证登录页面是顶级页面*/

        if(window.top!==window.self){window.top.location=window.location};

    </script>

</head>

<body layadmin-themealias="default">

<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" >

    <div class="layadmin-user-login-main">

        <div class="layadmin-user-login-box layadmin-user-login-header" style="margin-top: 50px;">

            <h2>{$title}{$description}</h2>

<!--            <p>{$description}</p>-->

        </div>

        <div class="layadmin-user-login-box layadmin-user-login-body" style="padding-top: 0px!important;">

            <form class="layui-form" onsubmit="return false;">

                <div class="layui-form-item">

                    <label class="layadmin-user-login-icon layui-icon layui-icon-username"

                           for="LAY-user-login-username"></label>

                    <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">

                </div>

                <div class="layui-form-item">

                    <label class="layadmin-user-login-icon layui-icon layui-icon-password"

                           for="LAY-user-login-password"></label>

                    <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">

                </div>

                <div class="layui-form-item">

                    <div class="layui-row">

                        {if condition="config('verify_type') eq 1"}

                        <div class="layui-col-xs7">

                            <label class="layadmin-user-login-icon layui-icon layui-icon-vercode"

                                   for="LAY-user-login-vercode"></label>

                            <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required" placeholder="图形验证码" class="layui-input">

                        </div>

                        <div class="layui-col-xs5">

                            <div style="margin-left: 10px;">

                                <img src="{:url('checkVerify')}" onclick="javascript:this.src='{:url('checkVerify')}?tm='+Math.random();" style="float:right;cursor: pointer" id="verify"/>

                            </div>

                        </div>

                        {elseif condition="config('verify_type') eq 2"/}

                        <div class="layui-col-xs12" id="geeFa">

                            <div id="embed-captcha"></div>

                        </div>

                        <p id="wait">正在加载验证码.... <i class="layui-icon layui-icon-loading-1 layui-icon layui-anim layui-anim-rotate layui-anim-loop"></i></p>

                        {/if}

                    </div>

                </div>

                <div class="layui-form-item" style="margin-bottom: 20px;">

                    <!--<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">-->

                    <!--<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>记住密码</span><i-->

                            <!--class="layui-icon layui-icon-ok"></i></div>-->

                    <!--<a href="javascript:;" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>-->

                </div>

                <div class="layui-form-item">

                    <button class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="LAY-login">登 录</button>

                </div>

            </form>

        </div>

    </div>



<!--    <div class="layui-trans layadmin-user-login-footer">-->
<!--        <p> <a href="{$icp_url}" target="_blank"> {$copyright}</a></p>-->
<!--    </div>-->

    <div class="layui-trans" style="position: absolute;left: 0;bottom: 0;width: 100%;line-height: 30px;padding: 20px;text-align: center;box-sizing: border-box;color: rgba(0, 0, 0, .5) !important;font-size:12px;">
        <p class="v-middle">
            <span>{$footcompany.web_site_wc_copyright}</span>
            <span><a href=" " rel="nofollow" target="_blank" style="color: rgba(0, 0, 0, .5) !important">{$footcompany.web_site_icp}</a></span>
            <span><a href="{$footcompany.web_site_wc_ps_url}" rel="nofollow" target="_blank"
                     style="color: rgba(0, 0, 0, .5) !important">{$footcompany.web_site_wc_ps}</a></span>
        </p>
    </div>

</div>

<script src="__JS__/layui/layui.all.js"></script>

<script src="__JS__/jquery.min.js"></script>

<script src="__JS__/wk.js"></script>

<script>

    $('#LAY-user-login-username').focus();

    var handlerEmbed = function (captchaObj) {

        $("#embed-submit").click(function (e) {

            var validate = captchaObj.getValidate();

            if (!validate) {

                $("#notice")[0].className = "show";

                setTimeout(function () {

                    $("#notice")[0].className = "hide";

                }, 2000);

                e.preventDefault();

            }

        });

        // 将验证码加到id为captcha的元素里

        captchaObj.appendTo("#embed-captcha");

        captchaObj.onReady(function () {

            $("#wait")[0].className = "layui-hide";

        });

    };

    var geeCheck = function(){

        $.ajax({

            // 获取id，challenge，success（是否启用failback）

            url: "{:url('getVerify',array('t'=>time()))}", // 加随机数防止缓存

            type: "get",

            dataType: "json",

            success: function (data) {

                // 使用initGeetest接口

                // 参数1：配置参数

                // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件

                initGeetest({

                    gt: data.gt,

                    challenge: data.challenge,

                    product: "float", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效

                    offline: !data.success, // 表示用户后台检测极验服务器是否宕机，一般不需要关注

                    width:"100%",

                }, handlerEmbed);

            }

        });

    }

    if('{:config('verify_type')}' == 2){

        geeCheck();

    }

    layui.use('form', function(){

        var form = layui.form;

        //监听提交

        form.on('submit(LAY-login)', function(data){

            $(".layui-btn").addClass('layui-disabled').attr('disabled','disabled').html('登录中... &nbsp;<i class="layui-icon layui-icon-loading-1 layui-icon layui-anim layui-anim-rotate layui-anim-loop"></i>');

            $.ajax({

                url:"{:url('doLogin')}",

                type:'post',

                dataType:'json',

                data:data.field,

                success:function(res){

                    if(res.code == 1){

                        setTimeout(function(){

                            location.href=res.url;

                        },1500);

                    }else{

                        layer.msg(res.msg,{icon:2,time:1500,anim: 6},function(index){

                            if('{:config('verify_type')}' == 2 && res.code != -3){

                                $("#wait").removeClass('layui-hide');

                                $('#embed-captcha').remove();

                                $('#geeFa').append('<div id="embed-captcha"></div>')

                                geeCheck();

                            }else if('{:config('verify_type')}' == 1){

                                $('#verify').attr("src","{:url('checkVerify')}?tm="+Math.random());

                            }

                            switch(res.code)

                            {

                                case -1:

                                    $('#LAY-user-login-username').focus();

                                    break;

                                case -2:

                                    $('#LAY-user-login-password').focus();

                                    break;

                                case -4:

                                    $('#LAY-user-login-vercode').focus();

                                    break;

                            }

                            layer.close(index);

                        })

                        $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled').text("登 录");

                        return false;

                    }

                }

                ,error:function(event, xhr, options, exc){

                    switch (event.status) {

                        case 403:

                            wk.error('403:禁止访问...');

                            break;

                        case 404:

                            wk.error('404:请求服务器出错...');

                            break;

                        case 500:

                            wk.error('500:服务器错误...');

                            break;

                    }

                    $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled').text("登 录");

                }

            })

        });

    });

    //防止页面后退

    history.pushState(null, null, document.URL);

    window.addEventListener('popstate', function () {

        history.pushState(null, null, document.URL);

    });



</script>

</body>

</html>